<template>
    <div id="backcont">
        <div class="ceshi-content">
            <div class="login-cont">
                <div class="ceshi-title">MBTI人格测试</div>
                <div class="ceshi-user">
                    <p>学号</p>
                    <el-input v-model="account" class="inptflex"  placeholder="请输入学号" />
                </div>
                <div class="ceshi-user">
                    <p>密码</p>
                    <el-input v-model="password" class="inptflex"  placeholder="请输入密码" />
                </div>
                <div>
                     <!--登录和注册的切换-->
                <div class="reg-view" @click="regi = regi == '登录' ? '注册' : '登录' ">
                   
                    <p>{{regi}}</p>
                </div>
                <!--登录或注册按钮-->
                <el-button  v-if ="regi == '注册'" @click="signin" type="success" class="ceshi-btn">登录</el-button>
                <el-button  v-else type="success" @click="register" class="ceshi-btn">注册</el-button>
                </div>
            </div>
        </div>
        
    </div>
</template>

<script>
import { reactive, toRefs,getCurrentInstance } from "vue";
import qs from "qs"
export default {
    setup(){
        const {proxy} = getCurrentInstance()
        const user = reactive({
            account:'',
            password:'',
            regi: '注册'
        })
        //登录
        const signin=async()=>{
            var form = new FormData()
            form.append('StudentNu', '2020082118')
            form.append('password', '2020082118')
                //const obj = qs.stringify({"StudentNu": "2020082118", "password": "2020082118"})
                const res = await new proxy.$request(proxy.$urls.m().login, form).modepost()
                console.log(res)
        }
        //注册
        const register=()=>{
        //     const obj = {account:user.account,password:user.password}
        //     const res = await proxy.$request(proxy.$urls.m()register,obj)
         }
        return {...toRefs(user),signin,register}
    }
    }
</script>

<style scoped>

</style>